Techniques for implementing batch processing in a database system

ABSTRACT

In accordance with embodiments, there are provided techniques for implementing batch processing in a multi-tenant database system. These techniques for implementing batch processing in a multi-tenant database system may enable embodiments to provide great flexibility to a tenant of the architecture to perform desired functions on content of the database while allowing the owner of the architecture schedule the processing of the functions on the content.

CLAIM OF PRIORITY

This continuation application is related to, and claims priority to, theutility patent application entitled “TECHNIQUES FOR IMPLEMENTING BATCHPROCESSING IN A DATABASE SYSTEM,” filed Jun. 12, 2013, havingapplication number of 13191.6,47 and attorney docket No 8956P074C(077USC1); and this continuation application is related to, and claimspriority to, the utility patent application entitled “TECHNIQUES FORIMPLEMENTING BATCH PROCESSING IN A MULTI-TENANT ON-DEMAND DATABASESYSTEM,” filed Aug. 25, 2008, having application Ser. No. 12/197,979 andattorney docket No. 8956P074/077US, the entire contents of both of whichare incorporated herein by reference.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

FIELD OF THE INVENTION

The current invention relates generally to databases. More particularlythe current invention relates to techniques for implementing batchprocesses on multi-tenant databases.

BACKGROUND

The subject matter discussed in the background section should not beassumed to be prior art merely as a result of its mention in thebackground section. Similarly, a problem mentioned in the backgroundsection or associated with the subject matter of the background sectionshould not be assumed to have been previously recognized in the priorart. The subject matter in the background section merely representsdifferent approaches, which in and of themselves may also be inventions.

In conventional database systems, users access their data resources inone logical database. A user of such a conventional system typicallyretrieves data from and stores data on the system using the user's ownsystems. A user system might remotely access one of a plurality ofserver systems that might in turn access the database system. Dataretrieval from the system might include the issuance of a query from theuser system to the database system. The database system might processthe request for information received in the query and send to the usersystem information relevant to the request. The efficient retrieval ofaccurate information and subsequent delivery of this information to theuser system has been and continues to be a goal of administrators ofdatabase systems.

Unfortunately, conventional database approaches might become inefficientif, for example, updating applications in the presence of complex datastructures. A database system may also process a query relatively slowlyif, for example, a relatively large number of users substantiallyconcurrently access the database system.

Accordingly, it is desirable to provide techniques enabling an owner ofthe database system to improve the ease of use of the database system.

BRIEF SUMMARY

In accordance with embodiments, there are provided techniques forimplementing batch processing in a multi-tenant on-demand databasesystem. These techniques for implementing batch processing in amulti-tenant on-demand database system can enable embodiments to easethe burden of manipulating data when updating the database. It may alsoreduce the computational load on the database by holding execution ofbatch processes until a desired time.

In an embodiment and by way of example, a method implementing batchprocessing in a multi-tenant on-demand database system includesoperating on instructions from a tenant to have the database systemperform processes on a subset of content stored on the database system.Identified among the instructions is an object associated with a classto execute a batch code interface that invokes multiple methods toschedule and execute functions upon the subset. The batch code interfaceis executed asynchronously with operations of the database system byinvoking the multiple methods, thereby providing a batch processingfacility to the tenant.

The present invention is described with reference to an embodiment inwhich an apparatus implements a batch process in a multi-tenant ondemand architecture. Although the invention is discussed with respect tosupporting multiple tenants; the present invention is not limited tomulti-tenant database systems. Embodiments may be practiced using otherdatabase architectures, i.e., ORACLES, DB2® by IBM and the like withoutdeparting front the scope of the embodiments claimed.

Any of the above embodiments may be used alone or together with oneanother in any combination. Inventions encompassed within thisspecification may also include embodiments that are only partiallymentioned or alluded to or are not mentioned or alluded to at all inthis brief summary or in the abstract. Although various embodiments ofthe invention may have been motivated by various deficiencies with theprior art, which may be discussed or alluded to in one or more places inthe specification, the embodiments of the invention do not necessarilyaddress any of these deficiencies. In other words, different embodimentsof the invention may address different deficiencies that may bediscussed in the specification. Some embodiments may only partiallyaddress some deficiencies or just one deficiency that may be discussedin the specification, and some embodiments may not address any of thesedeficiencies.

BRIEF DESCRIPTION OF THE DRAWINGS

In the following drawings like reference numbers are used to refer tolike elements. Although the following figures depict various examples ofthe invention, the invention is not limited to the examples depicted inthe figures.

FIG. 1 illustrates a representative architecture for batch processing ina multi-tenant database system in accordance with one embodiment of thepresent invention;

FIG. 2 is a simplified schematic view showing relationships betweentenant information and objects stored on a database shown in FIG. 1 inaccordance with the present invention;

FIG. 3 is a plan view showing the relation between methods of a batchcode interface and objects in a database shown in FIG. 1;

FIG. 4 is a simplified plan view showing a single batch code interfaceand the sequence in which a method associated therewith is called fordifferent sub-groups of objects;

FIG. 5 is an operational flow diagram illustrating a high level overviewof a method for batch processing in a multi-tenant database system inaccordance with one embodiment;

FIG. 6 is simplified plan view showing multiple batch code interfacesand the sequence in which requests to invoke methods associated with themultiple batch code interfaces occurs in accordance with an embodimentof the present invention;

FIG. 7 illustrates a block diagram of an example of a representativesystem in which the architecture, shown in FIG. 1, may be practiced;

FIG. 8 is a detailed block diagram of a user system, shown in FIG. 7;and

FIG. 9 illustrates a block diagram of an embodiment of elements of FIG.7 and various possible interconnections between these elements.

DETAILED DESCRIPTION

Systems and methods are provided to implement batch processing in amulti-tenant on-demand database system. As used herein, the termmulti-tenant database system (MTS) refers to those systems in whichvarious elements of hardware and software of the database system may beshared by one or more users. For example, a given application server maysimultaneously process requests for a great number of customers, and agiven database table may store rows for a potentially much greaternumber of customers.

FIG. 1 illustrates a database architecture 10 that includes server sidefacilities 12 and client side facilities 14 in data communication over anetwork 16. Server side facilities 12 includes processor sub-system 18,memory space 20, in data communication therewith, and network interfaceresources 22 in data communication with both memory space 20 andprocessor sub-system 18. Processor sub-system 18 may be any knownprocessor subsystem in the art, e.g., the CORE DUO® or the CORE 2 DUO®from Intel Corporation of Santa Clara, Calif. Memory space 20 includesdrive storage 21, shown as one or more hard drives 23 and 24, as well asdata and instruction registers, shown as 28, and volatile andnon-volatile memory shown as 30. Data communication network 16 may beany network or combination of networks of devices that communicate withone another. Network 16 can be any one or any combination of a LAN(local area network), WAN (wide area network), telephone network,wireless network, point-to-point network, star network, token ringnetwork, hub network, or other appropriate configuration. As the mostcommon type of computer network in current use is a TCP/IP (TransferControl Protocol and Internet Protocol) network, such as the globalinter-network of networks often referred to as the “Internet” with acapital “I,” that network will be used in many of the examples herein.However, it should be understood that the networks that the presentinvention might use are not so limited, although TCP/IP is a frequentlyimplemented protocol.

Server side facilities 12 access to a database 32 by multiple users25-27 of client side facilities 14 over data communication network 16.To that end, network interface resources 22 include a plurality ofvirtual portals 33-35. Each virtual portal 33-35 provides an “instance”of a portal user interface coupled to allow access to database 32.Typically, tenants obtain rights to store information, referred to astenant information 38 and 40, on database 32 and make the sameaccessible to one or more users 25-27 to whom the tenant providesauthorization. This is typically achieved by rental agreements betweenthe tenant and an owner/provider of architecture 10. In this manner,architecture 10 provides an on-demand database service to users 25-27that are not necessarily concerned with building and/or maintaining thedatabase system; rather, these functions are addressed between thetenant and the owner/provider.

With architecture 10, multiple users 25-27 may access database 32through a common network address, in this example a universal resourcelocator (URL). In response, web-pages and other content may be providedto users 25-27 over network 16. The resources of database 32 that users25-27 may access can be different, depending on user's 25-27 security orpermission level and/or tenant association. As a result, data structuresincluded in tenant information is managed so as to be allocated at thetenant level, while other data structures might be managed at the userlevel. Because architecture 10 supports multiple tenants includingpossible competitors, security protocols 42 and other system software44, stored for example on hard drive 26, maintain applications andapplications' use to only those users 25-27 with proper access rights.Also, because many tenants may desire access to architecture 10 ratherthan maintain their own system, redundancy, up-time, and backup areadditional functions that may be implemented in architecture 10. Inaddition to user-specific data and tenant specific data, server sidefacilities 12 might also maintain system level data usable by multipletenants or other data. Such system level data might include industryreports, news, postings, and the like that are sharable among tenants.

For example, in certain embodiments architectures 10 may allow users25-27 associated with the tenant, referred to as tenant users, access toa sub-portion of the content of the database information that the tenantmay be allowed to access. The sub-portion that any one of users 25-27may access may be the same as, or different from, the sub-portion thatthe remaining users 25-27 may access. Users 25-27 not associated with atenant would not be allowed access to information 38 and 40. Forexample, assume users 25 and 26 are associated with the tenantcorresponding to tenant information 38 and not associated with thetenant corresponding to tenant information 40. Users 25 and 26 would notbe allowed access to tenant information 40 and would be allowed accessto tenant information 38 or a sub-portion thereof. In the presentexample, user 25 may be allowed access to a first portion of tenantinformation 38 and user 26 may be allowed access to a second portion oftenant information 38, which is mutually exclusive. Similarly, were user27 associated with the tenant corresponding to tenant information 40 andnot the tenant corresponding to tenant information 38, user 27 would beallowed to access tenant intimation 40, or a portion thereof, and nottenant information 38. It is possible, however, that one of users 25-27are associated to the tenants corresponding to both sets of tenantinformation 38 and 40.

Virtual portals 33, 34 and 35 facilitate providing resources of database32 on behalf of a tenant to users 25-27 associated with the tenant. Eachuser 25-27 logs into one of virtual portals 33, 34 and 35 to accessresources of database 32 through a unique uniform resource locator (URL)or other type of address. Based on the URL and other identifyinginformation associated with users 25-27, architecture 10 may determinethe resources of database 32 users 25-27 may access. For example, user25 communicates with database through virtual portal 33, user 26communicates with database 32 through virtual portal 34, and user 27communicates with database through virtual portal 35. It is possible,however, that all users 25-27 may use a common portal, as well. To thatend, users 25-27 desiring to access resources of database 32 employvirtual portals 33, 34 and 35 to validate against the information storedon architecture 10, corresponding to the user 25-27 requesting access toa sub-portion of content on database 32.

The result of the communications between users 25-27 and server sidefacilities 12 results in multiple processes 50, 52 and 54 being executedby processor sub-system 18. Thus, it is desired that processorsub-system 18 be capable of providing uninterrupted interaction withusers 25-27 to provide online transaction processing (OLTP) to each ofusers 25-27. As a result, each of processes 50, 52 and 54 may includeone or more threads of execution. This is shown as threads 56 associatedwith process 50, threads 58 associated with process 52 and threads 60associated with process 54.

Referring to both FIGS. 1 and 2, it is desired that tenants and/or users25-27 associated therewith have the ability to easily and reliablymanipulate large volumes of data while avoiding consuming excessiveresources of processor sub-system 18. The challenge presented by theseseemingly contravening requirements is realized by realizing the natureof the use of architecture 10 by tenants. An example of a tenant may beas company that employs a sales force where each salesperson uses serverside facilities 12 to manage their sales process, such as by amanagement representative of the tenant, e.g. Vice President of Sales,the Chief Executive Officer of the tenant and the like. In this fashion,architecture facilitates Customer Relations Management (CRM). Thus, oneor more of users 25-27 may be a salesperson that maintains informationapplicable to that salesperson's sales process and may be different frominformation related to other salespersons' sales process. Although thesales force accessing database 32 is represented by three users 25-27,in practice hundreds of salespersons would access database 32. Moreover,sales process data of each sales person may include thousands of files.An example of sales process data may include, without limitation,contact data, leads data, customer follow-up data, performance data,goals and progress data applicable to that salesperson's personal salesprocess.

Moreover, to facilitate management of this information, the tenantassociated with the salespersons may restrict each of the salespersonsto access specific sales process information. However, a tenant, orrepresentative thereof based upon a contractual relationship between thesalesperson and the representative, may be able to view all sale processinformation for the salespersons associated with the tenant. An exampleof a contractual relationship is a managerial/supervisory relationship.The managerial relationship between the salesperson and the tenantrepresentative may provide the representative with a higher permissionlevel when compared to the permission level of the salesperson, because,inter alia, the tenant representative may be a manager/supervisor of thesalesperson. Another contractual relationship may be the principle agentrelationship wherein the tenant representative has no day-to-daymanagement responsibility of the salesperson. Nonetheless, as therepresentative of the principle, e.g., the tenant, the representativemay view all of the salesperson information, because the salespersonsmay be deemed to be merely agents of the tenant.

Tenant information 38 and 40 may be viewed as a collection of objects,such as a set 61-66 of logical tables, containing data fitted intopredefined categories. This is shown as data objects 67-73 with respectto tenant set 63. A “table” is one representation of a data object, andmay be used herein to simplify the conceptual description of objects andcustom objects according to the present invention. It should beunderstood that “table” and “object” may be used interchangeably herein.Thus, it is realized that large amounts of objects having complexinterrelationships may be subject to a request for manipulation, forexample, a managerial relationship between a salesperson or thousands ofsalespersons, may change. To implement this change may require asubstantial percentage of the computational resources of the processorsub-system 18. Thus, manipulating such a large quantity of data objects67-73 may interfere with the computing experience of users 25-27 takingadvantage of OLTP processes 50, 52, and 54.

Referring to both FIGS. 1 and 3, one embodiment of the current inventionfacilitates manipulation of large quantities of data objects in responseto receiving request from a tenant and/or users 25-27 while reducing therisk of interference, or perceived interference, with OLTP processes 50,52 and 54. This is achieved by providing system software 44 with a batchengine 75 that carries-out requests for manipulation of a large numberof objects 67-73 asynchronously with respect to OLTP processes 50, 52and 54. Batch engine 75 facilitates scheduling execution of functions onlarge quantities of data at the request of a tenant and/or user 25-27,referred to as a batch request. To that end, batch engine 75 includes abatch code interface 76 that is implemented when a class 77 of one ormore special objects, shown as 75-80, is included in instructions from atenant and/or a user 25-27. The instructions are typically included intenant information 38 and 40 or may be received, in situ, during one ofOLTP processes 50, 52 and 54. Batchable code interface 76 invokesmultiple methods 81-83 that function to schedule and execute batchrequests. Pseudo code for an example of batchable code interface 76written using the Apex language available from Salesforce.com, inc. ofSan Francisco, Calif. is as follows:

/** * Returns a Query Locator object, which is a handle to the fullresult set * to be processed. */ Database.Query Locator start(Database.BatchableInput stateVar); /** * Each iteration over the Query Locatorobject returned in the start( ) * method will produce a batch of SObjectrecords to process. This method *will be called for every batch, andwill perform whatever work is defined * by the Apex developer. */ voidexecuteBatch(Database.BatchableInput stateVar, SObject[ ] scope); /** *After completing all invocations of executeBatch, which means all data *identified in the start( ) method has been processed, this method willbe * called and allows a developer to implement their own cleanup,notify, * etc. behavior. */ void finish(Database.BatchableInput stateVar).

First method 81 is the Database.QueryLocator start (START) method thatidentifies the full set 84 of objects 85-91 that is the subject of thebatch request. Second method 82 is the void executeBatch (EXECUTE)method that executes the manipulation defined by a tenant and or user25-27. Third method 83 is the void finish (FINISH) method that isinvoked after START method 81 and EXECUTE method 82 have completed. Theresult that occur in response to invocation of FINISH method 83 isdefined by tenants and/or users 25-27 and may include sendingnotifications to users 25-27 that the batch process is complete and/orfurther details concerning the changes to tenant information 38 and 40as a result of the batch process.

To ensure that a single batch process does not consume too great aquantity of resources of processor sub-subsystem 18, START method 81calls a QueryLocator object 92 that points to a maximum number ofobjects that may be scheduled for uninterrupted processing.Specifically, the QueryLocator object 92 represents a server sidedatabase cursor persisted on architecture 10. As a result, QueryLocatorobject 92 will retrieve a predetermined maximum number of objects 85-91from set 84. As shown QueryLocator object 92 retrieves four differentsub-groups 100, 101, 102 and 103, of objects 85-91. Sub-group 100includes objects 85 and 86; sub-group 101 includes objects 87 and 88;sub-group 102 includes objects 89 and 90; and sub-group 103 includesobject 91. As a result, EXECUTE method 82 is invoked four times byprocess 94, each time operating on a different one of sub-groups100-103. In operation, the total number of objects in a result set thatis identified by START method 81 may be in the millions. Therefore, thepredetermined number retried by QueryLocator object 92 is a quantitydefined by the owner of architecture 10 and is dependent upon severaltechnological and business factors, such as the processing capacity ofarchitecture 10 and/or the business arrangements with tenants and/or apriori information concerning the consumption history of the resourcesof architecture 10. For example, an instance of batch engine 44 is aprocess 94 executing in processor sub-system 18, which, inter alia,which monitors the operation of architecture 10 to determine anappropriate time for invoking methods 81-83. This may be determined bydynamically monitoring other processes executing in processor sub-system18, such as OLTP process 50, 52 and 54 and/or on a particular timeduring which consumption of architecture has historically been reduced,e.g., on Christmas day, Sundays and the like. Additionally, process 94monitors the number of batch requests that architecture has scheduledfor different tenants and determines the sequence in which to executethe EXECUTE method 82.

Referring to FIGS. 1, 3, 4 and 5, in operation, upon determining that abatch request is present, process 94 enqueues, at step 500, the batchrequest in a queue, referred to as a request queue 110, associated withmemory space 20, i.e., in registers 28. As shown, request 112corresponds to batch code interface 76. To facilitate invocation ofEXECUTE method 82, process 94 enqueues an identifier of one ofsub-groups 100-103 of objects 85-91 that will be the subject of EXECUTEmethod 82 in a second queue, referred to as execute queue 114,associated with memory space 20, i.e., in registers 28. Specifically,upon dequeue of request 112, process 94 instantiates the objectassociated therewith, for example one of objects 78-80 and invokes STARTmethod 81 at step 502. START method 81 returns, at step 504.QueryLocator object 92 that contains the identifier to the first batchof the result set of objects, for example sub-group 100 containingobjects 85 and 86. As a result, process 94 enqueues execute queue 114with the identifiers of sub-group 100 for example as identifier 115 atstep 506. Upon dequeue of identifier 115, a queryMore( ) method is runby process 94 that returns an SObject array, which is an arrayrepresentation of an instance of an entity or a row in 32. SObject arraycontains the objects that are to be the subject of EXECUTE method 82 atstep 508. At step 510, process 94 then passes the SObject array toexecute method 82 to perform the manipulation defined by method 82. Atstep 512 queryMore method determines whether additional objects 85-91 ofset 84 remain to be subjected to EXECUTE method 82. If so, then process94 enqueues execute queue 114 with the identifiers 117 for the nextsub-group 101 of objects 87 and 88, at step 514. Following step 514,EXECUTE method 82 is invoked for the additional objects 85-91 of set 84;thereafter, step 512 occurs. Steps 514 and 512 repeat for the remainingsub-groups 102 and 103 having identifiers 119 and 121, respectfully.Finish method 83 is invoked at step 516 once it is determined at step512 that there are no additional sub-groups of object that are to besubjected to EXECUTE method 82. It should be noted that process 94 willetiquette only a single sub-group in execute queue 114 for a givenrequest 112. In this manner, when multiple batch code interfaces arequeued in request queue 110 no one batch code interface prevented fromhaving methods associated therewith invoked for an unreasonable lengthof time/process cycles.

Referring to FIGS. 1 and 6, database 32 is shown having four differentbatch code interfaces 276, 376, 476 and 576. For purposes of the presentexample batch code interfaces 276 and 376 correspond to a common tenantand batch code interfaces 476 and 576 correspond to two differenttenants, which are also different from the tenant corresponding to batchcode interfaces 276 and 376. Batch code interface 276 has a START method281, an EXECUTE method 282 and a FINISH method 283; batch code interface376 has a START method 381, an EXECUTE method 382 and a FINISH method383; batch code it face 476 has a START method 481, an EXECUTE method482 and a FINISH method 483; and batch code interface 576 has a STARTmethod 581, an EXECUTE method 582 and a FINISH method 583. To scheduleeach of batch code interface 276, 376, 476 and 576 for execution,process 94 places the requests in request queue 110. As shown, request122 corresponds to batch code interface 276, request 124 corresponds tobatch code interface 376, request 126 corresponds to batch codeinterface 476 and request 128 corresponds to batch code interface 576.To facilitate invocation of the EXECUTE methods 282, 382, 482 and 582,process 94 enqueues an identifier of one of several sub-groups (notshown) of objects (not shown) that will be the subject of one of EXECUTEmethods 282, 382, 482 and 582 in EXECUTE queue 120. As shown, EXECUTEqueue 120 includes identifiers 130-143. Identifiers 130, 134, 138, 140,142 and 143 identify objects that are the subject of EXECUTE method 282.Identifiers 131, 135, 139 and 141 identify objects that are the subjectof EXECUTE method 382. Identifiers 123 and 127 identify objects that arethe subject of EXECUTE method 482. Identifiers 133 and 137 identifyobjects that are the subject of EXECUTE method 582.

With request 122 being first in request queue 110, start method 281occurs before any of the remaining methods 282-283, 381-383, 481-483 and581-583. However, this does not mean that request 122 will be completedbefore any of the remaining requests, 124, 126 and 128. Rather, asshown, multiple invocations of each of EXECUTE methods 282, 382, 482 and582 occur in response requests 122, 124, 126 and 128, respectively. Theinvocation of any one of EXECUTE methods 282, 382, 482 and 582 isinterleaved with the remaining EXECUTE methods 282, 382, 482 and 582.This results in at least one of EXECUTE methods 282, 382, 482 and 582being invoked before completion of at least one request 122, 124, 126and 128, in the present example. In this manner, no one request 122,124, 126 and 128 prevents any of the remaining requests 122, 124, 126and 128 to be subjected to an unreasonable amount of latency beforeexecution of the methods associated therewith occurs. As shown, method282 is invoked to operate upon a first sub-group of objects associatedwith identifier 130. However, before method 282 operates on a secondsub-group of objects associated with identifier 134, method 382 isinvoked to operate on a sub-group of objects associated with identifier131, method 482 is invoked to operate on a sub-group of objectsassociated with identifier 132 and method 582 is invoked to operate on asub-group of objects associated with identifier 133. Thus, process 94interleaves invocation of the various methods 282, 382, 482 and 582associated with requests 122, 124, 126 and 128, respectively.

Referring to both FIGS. 1 and 7 a block diagram of a server system 600employed to implement architecture 10 is shown as including multipleuser systems 602 included in client side facilities 14 and in datacommunication with server system 600 over network 16. Server system 600includes a processor sub-system 18, application platform 606, networkinterface 22, and drive storage 31 that includes database 32. Inaddition server system 600 includes program code 614, and process space616. Program code 614 may include, among other code, code to facilitatea tenant to control the look-and-feel of the experience users 25-27 havewhen accessing database 32. Process space 616 facilitates execution ofMTS system processes and tenant-specific processes, such as runningapplications as part of an application hosting service. Additionalprocesses that may execute on server system 600 include databaseindexing processes. In other embodiments, server system 600 may not haveall of the components listed and/or may have other elements instead of,or in addition to, those listed above. Server system 600, and additionalinstances of an MTS, where more than one is present, and all componentsthereof may be operator configurable using applications includingcomputer code to run using a central processing unit such as processorsub-system 18.

Application platform 606 may be a framework that allows the applicationsof architecture 10 to run, such as the hardware and/or software, e.g.,the operating system. In an embodiment, application platform 606 mayenable creation, managing and executing one or more applicationsdeveloped by the owner/provider of architecture 10, users 25-27accessing architecture 10 via user systems 602, or third partyapplication developers accessing architecture 10 via user systems 602.

In one embodiment, server system 600 implements a web-based customerrelationship management (CRM) system. For example, in one embodiment,server system 600 includes application servers configured to implementand execute CRM software applications as well as provide related data,code, forms, webpages and other information to and from user systems 602and to store to, and retrieve from, database system related data,objects, and Webpage content. Architecture 10 typically stores data formultiple tenants in the same physical data object, however, tenant datatypically is arranged so that data of one tenant is kept logicallyseparate from that of other tenants so that one tenant does not haveaccess to another tenant's data, unless such data is expressly shared.In certain embodiments, server system 600 implements applications otherthan, or in addition to, the CRM application discussed above. Forexample, server system 600 may provide tenant access to multiple hosted(standard and custom) applications, including a CRM application. User(or third party developer) applications, which may or may not includeCRM, may be supported by the application platform 606, which managescreation, storage of the applications into one or more database objectsand executing of the applications in a virtual machine in the processspace of server system 600.

Referring to FIGS. 1, 7 and 8, to facilitate web-based CRM, user systems602 might communicate with server system 600 using TCP/IP and, at ahigher network level, use other common Internet protocols tocommunicate, such as HTTP, FTP, AFS, WAP, etc. To that end, user systems602 may be any computing device capable of interfacing directly orindirectly to the Internet or other network connection, such as desktoppersonal computer, workstation, laptop, PDA, cell phone, or any wirelessaccess protocol (WAP) enabled device and the like running an HTTP client49. An example of a user system 602 includes a processor system 620, asmemory system 622, an input system 624, and output system 626. Processorsystem 620 may be any combination of one or more processors. Memorysystem 622 may be any combination of one or more memory devices,volatile, and/or non-volatile memory. A portion of memory system is usedto run operating system 628 in which HTTP client 630 executes. Inputsystem 624 may be any combination of input devices, such as one or morekeyboards, mice, trackballs, scanners, cameras, and/or interfaces tonetworks. Output system 626 may be any combination of output devices,such as one or more monitors, printers, and/or interfaces to networks.HTTP client 630 allows users 25-27 of users systems 602 to access,process and view information, pages and applications available to itfrom server system 600 over network 16. Examples of HTTP client 630include various browsing applications, such as Microsoft's InternetExplorer browser, Netscape's Navigator browser, Opera's browser, or aWAP-enabled browser in the case of a cell phone, PDA or other wirelessdevice, or the like. Access is gained to requisite tenant information 38and 40 by entering the URL (not shown) into the URL box 632 of HTTPclient 630. The URL directs users 25-27 to the appropriate virtualportal for to determine authorization and permission level to access therequisite tenant information.

Data corresponding with each user 25-27 may be separate from the datacorresponding to the remaining users 25-27 regardless of the tenantassociated with users 25-27; however, some data might be shared oraccessible by a plurality of users 25-27 or all of users 25-27associated with a tenant. Titus, there might be some data structuresmanaged by server system 600 that are allocated at the tenant levelwhile other data structures might be managed at the user level. Becausean MTS typically support multiple tenants including possiblecompetitors, the MTS should have security protocols that keep data,applications, and application use separate. Also, because many tenantsmay opt for access to an MTS rather than maintain their own system,redundancy, up-time, and backup are additional functions that may beimplemented in the MTS. In addition to user-specific data and tenantspecific data, server system 600 might also maintain system level datausable by multiple tenants or other data. Such system level data mightinclude industry reports, news, postings, and the like that are sharableamong tenants.

According to one embodiment, server system 600 provides securitymechanisms to keep each tenant's data separate unless the data isshared. If more than one MTS is used, they may be located in closeproximity to one another (e.g., in a server farm located in a singlebuilding or campus), or they may be distributed at locations remote fromone another (e.g., one or more servers located in city A and one or moreservers located in city B). As used herein, each MTS could include oneor more logically and/or physically connected servers distributedlocally or across one or more geographic locations. Additionally, theterm “server” is meant to include a computer system, includingprocessing hardware and process space(s), and an associated storagesystem and database application (e.g., OODBMS or RDBMS) as is well knownin the art. It should also be understood that “server system” and“server” are often used interchangeably herein. Similarly, the databaseobject described herein can be implemented as single databases, adistributed database, a collection of distributed databases, a databasewith redundant online or offline backups or other redundancies, etc.,and might include a distributed database or storage network andassociated processing intelligence.

Referring to FIG. 9, a specific embodiment of a server system 800includes database 32, as discussed above, as well as processorsub-system 18 and a network interface 122. In addition, server system800 includes a user interface (UI) 802, application program interface(API) 804, PL/SOQL 806, save routines 808, an application setupmechanism 810, applications servers 812 ₁-812 _(N), system process space814, tenant processes 50, 52 and 54, tenant management processes 816.User interface (UI) 802, application program interface (API) 804,PL/SOQL 806, save routines 808, an application setup mechanism 810,tenant processes 50, 52 and 54, tenant management processes 816 areshown as processes running in processor sub-system 18. However, itshould be noted that the computer readable code to implement theprocesses may be stored on drive storage 31. In other embodiments,server system 800 may not have the same elements as the listed aboveand/or may have other elements instead of, or in addition to, thoselisted above. Network interface 122 is implemented as a plurality ofHTTP application servers 812 ₁-812 _(N).

Referring to FIGS. 1, 6 and 8, each application server 812 ₁-812 _(N)may be configured to service requests of user systems 602 for access todatabase 32. In this configuration, tenant information 38 and 40consists of different information storage areas that may physicaldifferentiation, e.g., different hard disks, and/or a logical separationof the information and may include application metadata 92 for each useror groups of users. For example, a copy of a user's most recently used(MRU) items might be included. Similarly, a copy of MRU items for anentire organization that is a tenant might be stored. UI 802 provides auser interface and API 804 provides an application programmer interfaceto server system 800 resident processes to users and/or developers atuser systems 602. The tenant data and the system data may be stored invarious databases, such as one or more Oracle™ databases.

Referring again to FIGS. 1, 6 and 8, it is not necessary that the one ormore HTTP application servers 812 ₁-812 _(N) be implemented as the solenetwork interface between server system 800 and network 16. Rather,other communication techniques might be used in conjunction with HTTPapplication servers 812 ₁-812 _(N) or in lieu thereof. In someimplementations, the interface between server system 800 and network 16includes load sharing functionality, such as round-robin HTTP requestdistributors to balance loads and distribute incoming HTTP requestsevenly over a plurality of servers. At least as for users 25-27 one ofHTTP application servers 812 ₁-812 _(N), each of the plurality ofservers has access to the MTS data; however, other alternativeconfigurations may be used instead.

Application platform 606 includes an application setup mechanism 810that supports application developers' creation and management ofapplications, which may be saved as metadata by save routines 808 forexecution by subscribers as one or more tenant process spaces 84 managedby tenant management process 86, for example. Invocations to suchapplications may be coded using PL/SOQL 806 that provides a programminglanguage style interface extension to API 804. A detailed description ofsome PL/SOQL language embodiments is discussed in commonly ownedco-pending U.S. patent application Ser. No. 11/859,498 entitled, METHODAND SYSTEM FOR ALLOWING ACCESS TO DEVELOPED APPLICATIONS VIA AMULTI-TENANT ON-DEMAND DATABASE SERVICE, by Craig Weissman, filed Sep.21, 2007, which is incorporated in its entirety herein for all purposes.Invocations to applications may be detected by one or more systemprocesses, which manage retrieving application metadata for thesubscriber making the invocation and executing the metadata as anapplication in a virtual machine.

Each HTTP application servers 812 ₁-812 _(N) may be communicably coupledto database systems, e.g., database 32, via a different networkconnection. For example, one HTTP application server 812 ₁ might becoupled via the network 16 (e.g., the Internet), another HTTPapplication servers 812 ₁-812 _(N) might be coupled via a direct networklink, and another one of HTTP application servers 812 ₁-812 _(N) mightbe coupled by yet a different network connection. Transfer ControlProtocol and Internet Protocol (TCP/IP) are typical protocols forcommunicating between HTTP application servers 812 ₁-812 _(N) anddatabase 32. However, it will be apparent to one skilled in the art thatother transport protocols may be used to optimize the system dependingon the network interconnect used.

In certain embodiments, each of HTTP application servers 812 ₁-812 _(N)is configured to handle requests for any user associated with anyorganization that is a tenant. Because it is desirable to be able to addand remove application servers from the server pool at any time for anyreason, there is preferably no server affinity for a user and/ororganization to a specific one of HTTP application servers 812 ₁-812_(N). In one embodiment, therefore, an interface system implementing aload balancing function (e.g., an F5 Big-IP load balancer) iscommunicably coupled between HTTP application servers 812 ₁-812 _(N) andthe user systems 602 to distribute requests to HTTP application servers812 ₁-812 _(N). In one embodiment, the load balancer uses a leastconnections algorithm to route user requests to HTTP application servers812 ₁-812 _(N). Other examples of load balancing algorithms, such asround robin and observed response time, also can be used. For example,in certain, embodiments, three consecutive requests from the same user25-27 could hit three different HTTP application servers 812 ₁-812 _(N),and three requests from different user systems 602 could hit a commonHTTP application server 812 ₁-812 _(N). In this manner, server system800 is multi-tenant, wherein server system 800 handles storage of, andaccess to, different objects, data and applications across disparateusers and organizations.

In certain embodiments, user systems 602 (which may be client systems)communicate with HTTP application servers 812 ₁-812 _(N) to request andupdate system-level and tenant-level data from server system 800 thatmay require sending one or more queries to database 32. Server system800 (e.g., an application server 812 in server system 800) automaticallygenerates one or more SQL statements (e.g., one or more SQL queries)that are designed to access the desired information. Database maygenerate query plans to access the requested data from the database.

While the invention has been described by way of example and in terms ofthe specific embodiments, it is to be understood that the invention isnot limited to the disclosed embodiments. To the contrary, it isintended to cover various modifications and similar arrangements aswould be apparent to those skilled in the art. For example, the presentprocesses may be embodied as a computer program product that includes amachine-readable storage medium (media) having instructions storedthereon/in which can be used to program a computer to perform any of theprocesses of the embodiments described herein.

Computer code for operating and configuring the server system tointercommunicate and to process webpages, applications and other dataand media content as described herein are preferably downloaded andstored on a hard disk, but the entire program code, or portions thereof,may also be stored in any other volatile or non-volatile memory mediumor device as is well known, such as a ROM or RAM, or provided on anymedia capable of storing program code, such as any type of rotatingmedia including floppy disks, optical discs, digital versatile disk(DVD), compact disk (CD), microdrive, and magneto-optical disks, andmagnetic or optical cards, nanosystems (including molecular memory ICs),or any type of media or device suitable for storing instructions and/ordata. Additionally, the entire program code, or portions thereof, may betransmitted and downloaded from a software source over a transmissionmedium, e.g., over the Internet, or from another server, as is wellknown, or transmitted over any other conventional network connection asis well known (e.g., extranet, VPN, LAN, etc.) using any communicationmedium and protocols (e.g., TCP/IP, HTTP, HTTPS, Ethernet, etc.) as arewell known. It will also be appreciated that computer code forimplementing embodiments of the present invention can be implemented inany programming language that can be executed on a client system and/orserver or server system such as for example, C, C++, HTML, any othermarkup language, Java™, JavaScript, ActiveX, any other scriptinglanguage, such as VBScript, and many other programming languages as arewell known may be used. (Java™ is a trademark of Sun Microsystems,Inc.). Therefore, the scope of the appended claims should be accordedthe broadest interpretation so as to encompass all such modificationsand similar arrangements.

1. A batch processing method in a multi-tenant database system, themethod comprising: operating on instructions from a tenant to have saiddatabase system perform processes on a subset of content stored on saiddatabase system; identifying from said instructions an object associatedwith a class to execute a batch code interface that invokes multiplemethods to schedule and execute functions upon said subset; andexecuting said batch code interface asynchronously with operations ofsaid database system by invoking said multiple methods, therebyproviding a batch processing facility to said tenant.
 2. The method asrecited in claim 1 wherein executing further includes invoking a thirdmethod in which said tenant is notified of completion of said first andsecond methods.
 3. The method as recited in claim 1 wherein executingfurther includes invoking said multiple methods, with one of saidmultiple methods identifying objects of said subset subject toprocesses.
 4. The method as recited in claim 1 wherein executing furtherincludes invoking said multiple methods, with one of said multiplemethods identifying objects of said subset subject to processes and anumber of iterations of a second method will be invoked to process saidobjects.
 5. The method as recited in claim 1 wherein executing furtherincludes invoking said multiple methods, with one of said multiplemethods identifying objects of said subset subject to processes andcalling a querylocator object to identify multiple subgroups of saidobjects to process in accordance with said second method.
 6. The methodas recited in claim 1 wherein executing further includes invoking saidmultiple methods, with one of said multiple methods identifying objectsof said subset subject to processes and calling a querylocator object toidentifying subgroups of said objects to process in accordance with saidsecond method and further including sequentially processing saidsubgroups.
 7. The method as recited in claim 1 further includingobtaining from additional tenants additional instructions to execute aplurality of additional batch code interfaces each of which invokesadditional multiple methods to schedule and execute additional functionsupon additional subsets of said content; with executing furtherincluding sequentially executing said additional functions and saidfunction.
 8. The method as recited in claim 1 further includingobtaining from additional tenants additional instructions to execute aplurality of additional batch code interfaces with each of saidplurality of additional batch code interfaces invoking an additionalexecution method multiple times to sequentially process multipleadditional subgroups of additional objects stored on said databasesystem, and processing one of said additional subgroups beforecompleting process of said subset.
 9. The method as recited in claim 1further including obtaining from additional tenants additionalinstructions to execute a plurality of additional batch code interfaceswith each of said plurality of additional batch code interfaces invokingan additional execution method multiple times to sequentially processmultiple additional subgroups of additional objects stored on saiddatabase system, with one of said multiple additional sub-groupsassociated with one of the additional tenants being queued to executebefore one of two consecutive subgroups of objects associated with oneof the remaining tenants of said additional tenants and after theremaining subgroup of said two consecutive subgroups.
 10. Amachine-readable medium carrying one or more sequences of instructionsfor implementing a batch processing method in a multi-tenant databasesystem when executed by one or more processors and cause said one ormore processors to carry out the steps of: operating on instructionsfrom a tenant to have said database system perform processes on a subsetof content stored on said database system; identifying from saidinstructions an object associated with a class to execute a batch codeinterface that invokes multiple methods to schedule and executefunctions upon said subset; and executing said batch code interfaceasynchronously with operations of said database system by invoking saidmultiple methods, thereby providing a batch processing facility to saidtenant.